<template>
  <el-dialog
  title="添加分类"
  :visible.sync="addSortdialogVisible"
  width="60%"
  @close="handleClose">
  
  <!-- 表单区域 -->
  <add-good-sort-form :sortList="fatherSortList"></add-good-sort-form>

  <!-- 按钮区域 -->
  <span slot="footer">
    <el-button @click="addSortdialogVisible = false">取 消</el-button>
    <el-button type="primary" @click="beforeSendAddSortFunc">确 定</el-button>
  </span>
  </el-dialog>
</template>

<script>
// 组件
import AddGoodSortForm from '@/views/Main/goods_manage/goodsSort/AddGoodSortForm';

export default {
  data() {
    return {
      addSortdialogVisible: false, // 控制dialog打开关闭
      fatherSortList: [], // 父级分类列表
    }
  },
  methods: {
    handleClose() {  // 关闭dialog初始化
      this.$bus.$emit('restForm');
    },
    openGoodSortDialog(data) { // 开启dialog组件
      this.fatherSortList = data;
      this.addSortdialogVisible = true;
    },
    beforeSendAddSortFunc() {
      this.$bus.$emit('beforeSendAddSortFunc');
    }
  },
  created() {
    this.$bus.$on('openGoodSortDialog', (data) => this.openGoodSortDialog(data));
    this.$bus.$on('closeGoodSortDialog', () => this.addSortdialogVisible = false);
  },
  destroyed() {
    this.$bus.$off('openGoodSortDialog');
    this.$bus.$off('closeGoodSortDialog');
  },
  components: {
    AddGoodSortForm
  }
}
</script>

<style lang="scss" scoped>

</style>